
#ifndef SX_QOPENGL_VIEWPORT_H
#define SX_QOPENGL_VIEWPORT_H

#include <sxQViewport.h>
#include <sxQGL_ViewportListener.h>
#include <sxOpenGL_Context.h>

using Sx::OpenGL::Graphics::Contexts::OpenGL_Context;

namespace Sx {
namespace QtInterface {

class QGL_Viewport;

class QOpenGL_Viewport : public QViewport, public QGL_ViewportListener {
	Q_OBJECT

public:
	QOpenGL_Viewport(QWidget* parent, const std::shared_ptr<OpenGL_Context>& context, unsigned int fps = 60u, Qt::WFlags flags = 0);
	QOpenGL_Viewport(QWidget* parent, QOpenGL_Viewport* share, unsigned int fps = 60u, Qt::WFlags flags = 0);
	virtual ~QOpenGL_Viewport();

	/* QGL Viewport Listener Interface */
	void initializeGL();
	void paintGL();
	void resizeGL(int width, int height);

	/* QViewport Interface */
	bool initialize();
	void render() const;
	void reRender() const;
	void resize(int width, int height);

	/* Qt Events */
	void resizeEvent(QResizeEvent* e);

protected:
	/* POINTER_OWNERSHIP: YES */
	QGL_Viewport* viewport;

	/* OpenGL Context */
	std::shared_ptr<OpenGL_Context> context;
};

}

}

#endif
